package boot3.mapper;

import org.apache.ibatis.annotations.*;
import boot3.pojo.Reservation;

import java.util.List;

@Mapper
public interface ReservationMapper {
    //根据学生的ID获取这个学生的所有预约记录
    @Select("select * from reservation where student_id=#{student_id}")
    public List<Reservation> selectAllReservationByStudentID(String student_id);
    //根据老师的ID获取这个老师的所有预约记录
    @Select("select * from reservation where teacher_id=#{teacher_id}")
    public List<Reservation> selectAllReservationByTeacherID(String teacher_id);
    //新建一个预约
    @Insert("insert reservation value(#{reserve_number},#{student_id},#{teacher_id},#{initiation_time}," +
            "#{state},#{start_time},#{end_time},#{purpose},#{place},#{teacher_name},#{student_name})")
    public Boolean createReservation(Reservation reservation);
    //获取所有的预约记录
    @Select("select * from reservation")
    public List<Reservation> selectAllReservation();
    //根据预约的编号删除指定的预约
    @Delete("delete from reservation where reserve_number=#{reserve_number}")
    public Boolean deleteReservation(String reserve_number);
    //根据预约编号批注一条预约
    @Update("update reservation set state='已通过' where reserve_number=#{reserve_number}")
    public Boolean updateState(String reserve_number);
    //根据预约的编号驳回一条预约且可以注明原因
    @Update("update reservation set state='已驳回',purpose=#{purpose} where reserve_number=#{reserve_number}")
    public Boolean updateStatePurpose(String reserve_number,String purpose);
}
